A typical computer system includes hardware (e.g., processor(s), memory, etc.) and software (e.g., operating system, user-level applications, etc.). The software is often executed as one or more threads. A thread corresponds to a sequence of instructions. A single processor may execute multiple threads concurrently. For example, the processor may begin executing a first thread, halt execution of the first thread, begin execution of a second thread, and then switch back to the first thread. Thus, by switching between threads, multiple threads may appear as if executing simultaneously. When executing a thread, an instruction may be executed that requires halting execution in order for an event, such as obtaining data from peripheral storage. While waiting for the data, the processor may switch to another thread to execute.
To further complicate the execution of the software on the hardware, in a multiprocessor system, multiple processors execute threads in parallel. Often, executing threads are shared amongst processors rather than dedicated to a single processor. For example, a thread may be first executed by processor X, and then switched to being executed by processor Y. Each processor in a multiprocessor system typically has a group of threads that are assigned to the processor. Specifically, a processor switches between the threads assigned to the processor. Further, threads may be reassigned from one processor to another processor by a scheduler.
When a scheduler determines which processor to assign a thread to, the scheduler often identifies the total number of threads assigned to each processor. In some cases, the thread is assigned to the processor with the lowest total number of threads assigned to the processor. Thus, the scheduler maintains load balancing of the threads across the processors.